package com.ystarkotlin.utils


import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import kotlin.properties.Delegates

class MyViewPagerAdapter : FragmentPagerAdapter {
    private var strings: List<String>? =null
    private var size: Int = 0
    private var fragments: List<Fragment>? = null

    constructor(fm: FragmentManager, list: List<Fragment>) : super(fm) {
        this.fragments = list
    }

    constructor(fm: FragmentManager, list: List<Fragment>, strings: List<String>) : super(fm) {
        this.fragments = list
        this.strings = strings
    }

    override fun getItem(position: Int): Fragment {
        return fragments!![position]
    }

    override fun getCount(): Int {
        return fragments!!.size
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return if (strings == null) null else strings!![position]
    }
}
